package com.ydy.file.controller;

import com.ydy.common.BaseController;
import com.ydy.common.constant.Constant;
import com.ydy.common.model.FileInfo;
import com.ydy.file.service.FileService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@RestController
public class ImageController extends BaseController {


    @Autowired
    private FileService fileService;


    /**
     * 上传图片
     * @param file
     * @return
     */
    @PostMapping(value = "/imageUpload")
    public Object imageUpload(@RequestParam(value = "file", required = false) MultipartFile file){

        FileInfo fileInfo = fileService.getFileInfo(file,Constant.FILE_IMAGE);
        return retResultVo(fileInfo);
    }
}
